import { IUser } from '@/interface';
import { $get, $post, $put } from '@/request/api';

export function fetchLogin({ id, password }) {
  return $post('/user/login', { id, password });
}

export function fetchUserInfo() {
  return $get('/user/get_user_info');
}

export function fetchUserList(params) {
  return $get('/user/list',
    params
  );
}

export function fetchUserDetail(id: number) {
  return $get(`/user/find/${id}`);
}

export function fetchUpdateUser({ id, username, status, avatar, desc }: IUser) {
  return $put(`/user/update/${id}`, {
    username,
    status,
    avatar,
    desc,
  }
  );
}
export function fetchUpdateUserRole({ id, user_roles }: IUser) {
  return $put(`/user/update_user_role/${id}`, {
    user_roles,
  });
}
